package com.chief.openfeign.service;

import com.chief.dubbo.DubboTestGateWayService;
import com.chief.dubbo.DubboTestService;
import com.chief.openfeign.OpenFeignTestService;
import com.chief.openfeign.mapper.ProductMapper;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class OpenFeignTestServiceImpl implements OpenFeignTestService {

    @Autowired
    private ProductMapper productMapper;

    @DubboReference
    private DubboTestService dubboTestService;
    @DubboReference
    private DubboTestGateWayService dubboTestGateWayService;

    @Override
    public Map<String, Object> openFeignTest(String code) {
        Map<String, Object> res = new HashMap<>();
        res.put("openFeignTest", code);
        res.put("db", productMapper.getProduct(1));
        res.put("test",this.dubboTestService.test("dubbo"));
        res.put("gateway",this.dubboTestGateWayService.test());
        return res;
    }

}